/* TCSS 590A - Cybernetics and Systems
 * Group Project - Modeling
 * By Barry Jones, Naren Meadem, Michael Pitts, Yuan Tao
 * Fall 2012, University of Washington, Tacoma
 */
package output;

/**
 * Provides the functionality of multiple data outs.
 * @author Michael Pitts
 * @version Oct 30, 2012
 */
public abstract class OutPutDelineated implements OutPut
{
	
	/** Stores the new line character or characters for this OutPut Object.*/
	private final String my_new_line;
	
	/** Stores the delineator character or characters for this OutPut Object.*/
	private final String my_delineator;
	
	/**
	 * Creates a new OutPutDelineated Object, with the given settings.
	 * @param the_new_line will be the new line marker for this OutPut.
	 * @param the_delineator will be the delineator for this OutPut.
	 */
	public OutPutDelineated(final String the_new_line, final String the_delineator)
	{
		my_new_line = the_new_line;
		my_delineator = the_delineator;
	}
	
	/**
	 * Creates a new Delineated OutPut object with the default new line and
	 * delineator strings from the OutPut Interface.
	 * @see OutPut#NEWLINE
	 * @see OutPut#DELINEATOR
	 */
	public OutPutDelineated()
	{
		this(OutPut.NEWLINE, OutPut.DELINEATOR);
	}

	public void newLine()
	{
		out(my_new_line);
	}

	public abstract void out(final String the_data);

	public void out(final String[] the_data)
	{
		for (int i = 0; i < the_data.length - 1; i++)
		{
			out(the_data[i]);
			delineate();
		}
		out(the_data[the_data.length-1]);
	}

	public abstract void out(final long the_data);

	public void out(final long[] the_data)
	{
		for (int i = 0; i < the_data.length - 1; i++)
		{
			out(the_data[i]);
			delineate();
		}
		out(the_data[the_data.length-1]);
	}

	public abstract void out(final double the_data);

	public void out(final double[] the_data)
	{
		for (int i = 0; i < the_data.length - 1; i++)
		{
			out(the_data[i]);
			delineate();
		}
		out(the_data[the_data.length-1]);
	}

	public abstract void close();
	
	public void delineate()
	{
		out(my_delineator);
	}

}
